package com.app.twth.ui.checkin;

import android.content.Context;
import android.view.View;

import com.app.twth.R;
import com.app.twth.base.RecyclerBaseAdapter;
import com.app.twth.databinding.ItemCheckinContainerListBinding;
import com.app.twth.utils.Utils;

import java.util.List;

/**
 * Created by admin on 2024/5/29.
 * Description:
 * Encoding: utf-8
 */
public class CheckinContainerAdapter2 extends RecyclerBaseAdapter<Container, ItemCheckinContainerListBinding> {

    private CheckinContainerAdapter.MyOnClickListener locationListener;

    public CheckinContainerAdapter2(Context context) {
        super(context);
    }

    public CheckinContainerAdapter2(Context mContext, List<Container> data, CheckinContainerAdapter.MyOnClickListener locationListener) {
        super(mContext);
//        this.data = data;
//        this.mInflater = LayoutInflater.from(mContext);
        this.locationListener = locationListener;
    }


    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_checkin_container_list;
    }

    @Override
    protected void onBindItem(ItemCheckinContainerListBinding itemBinding, Container receiving) {
        itemBinding.tvContainerNo.setText(receiving.getContainerNo() + "");
        itemBinding.tvInboundNo.setText(Utils.getStr(receiving.getInboundNo()) + "");
        if (Utils.getStr(receiving.getInboundNo()).equals("")) {
            itemBinding.tvInboundNo.setVisibility(View.GONE);
        } else {
            itemBinding.tvInboundNo.setVisibility(View.VISIBLE);
        }
        itemBinding.tvExpected.setText(Utils.getStr(receiving.getForecastArrivedDate()) + "");
        itemBinding.tvDropped.setText(Utils.getStr(receiving.getArrivedDate()) + "");
        itemBinding.layout.setOnClickListener(v -> {
            locationListener.OnClick(receiving);
        });
    }
}
